package com.vecharm.app.manager

import android.util.Log
import com.danikula.videocache.HttpProxyCacheServer
import com.ling.sdk.app.App
import java.io.File

object VideoCacheManager {

 /*   private var proxy: HttpProxyCacheServer? = null

    fun getProxy(): HttpProxyCacheServer {
        return proxy ?: newProxy().apply { proxy = this }
    }

    private fun newProxy(): HttpProxyCacheServer {

        return HttpProxyCacheServer.Builder(App.app)
                .cacheDirectory(getCacheFile())
                .build()
    }
*/
     fun cache(url: String) {
//        getProxy().getProxyUrl(url)
    }

    fun getProxyUrl(url: String): String {
//        return if (getProxy().isCached(url)) getProxy().getProxyUrl(url) else url
//        return getProxy().getProxyUrl(url)
        return url
    }

    private fun getCacheFile(): File {
        val file = File(App.app.externalCacheDir, "video-cache")
        if (!file.exists() && !file.mkdir()) {
            Log.e("VideoCacheManager", """getSonicCacheDir error:make dir(${file.absolutePath}) fail!""")
        }
        return file
    }
}